home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 2003 June / macformat-130.iso / mac / Reviewed⁄Demos / Spearhead Demo / demota / pak1.pk3 / anim / smoking.scr < prev    next >
Encoding:
Text File  |  2002-10-21  |  3.6 KB  |  141 lines

  1. //------
  2. // Smoking
  3. //------
  4. // This is a sub script that can be called as a subroutine
  5. // whenever an animation behavior wants to smoke
  6.  
  7. //println "smoking.scr"
  8.  
  9. //An animation behavior that wants to smoke must call this during its initialization...
  10. //===================================================================================
  11. SmokeCigaretteInit:
  12.     if (self.smokinginitialized != "yes")
  13.     {
  14.         //println "smoking init"
  15.         self.cigarettelit = 0
  16.         self.smokesremaining = 0
  17.         self.cigarettesremaining = randomint 10
  18.         self.smokinginitialized = "yes"
  19.         self.nextsmoketime = level.time + ((randomint 100)/10) + 5
  20.  
  21.         // Initialise say manager
  22.         self waitthread anim/SayManager.scr::Init
  23.     }
  24. end
  25.  
  26.  
  27. //===================================================================================
  28. SmokeCigarette:
  29.  
  30.     if ( (self.bIAmASmoker != NIL) && (self.bIAmASmoker == 0) )
  31.     {
  32.         end
  33.     }
  34.  
  35.     //Should I smoke?
  36.     local.randnum = randomint 100
  37.     
  38.     if (self.cigarettelit == 0)
  39.     {
  40.         if ( (level.time > self.nextsmoketime) && (local.randnum < 30) )
  41.         {
  42.             if (self.cigarettesremaining > 0)
  43.             {
  44.                 //println "Lighting up cigarette"
  45.                 
  46.                 //stop, light up cigarette
  47.                 self.blendtime = 0.5
  48.                 self setmotionanim smoking01  
  49.                 self thread anim/SayManager.scr::SayManager smoking_lightup_face 2
  50.                 self waittill flaggedanimdone
  51.                 
  52.                 self.cigarettelit = 1
  53.                 self.smokesremaining = randomint(3) + 4
  54.                 self.cigarettesremaining = self.cigarettesremaining - 1
  55.                 
  56.                 //put down cigarette
  57.                 self.blendtime = 0.5
  58.                 self setmotionanim smoking02  
  59.                 self thread anim/SayManager.scr::SayManager smoking_firstinhale_face 2
  60.                 self waittill flaggedanimdone
  61.                 
  62.                 //println "Done lighting up cigarette"
  63.             }
  64.         }
  65.     }
  66.     else if (local.randnum <70)
  67.     {
  68.         if (self.smokesremaining > 0)
  69.         {
  70.             //println "Puffing up cigarette"
  71.             
  72.             //puff cigarette
  73.             self.blendtime = 0.5
  74.             self setupperanim (smoking03) 
  75.             //self setmotionanim (aim_leg_stance)
  76.             self thread anim/SayManager.scr::SayManager smoking_inhale_face 2
  77.             self waittill upperanimdone
  78.             
  79.             self.smokesremaining = self.smokesremaining - 1
  80.             
  81.             //println "Done puffing up cigarette"
  82.         }
  83.         else
  84.         {
  85.             //println "Throwing away cigarette"
  86.             
  87.             local.randnum = randomint 100
  88.  
  89.             if (local.randnum > 50)
  90.             {
  91.                 //put down and extinguish cigarette
  92.                 self.blendtime = 0.5
  93.                 self setmotionanim smoking04  
  94.                 self thread anim/SayManager.scr::SayManager smoking_buttout_face 2
  95.                 self waittill flaggedanimdone
  96.             }
  97.             else
  98.             {
  99.                 //put down and throw cigarette 
  100.                 self.blendtime = 0.5
  101.                 self setupperanim (smoking05) 
  102.                 //self setmotionanim (aim_leg_stance)
  103.                 self waittill upperanimdone
  104.             }
  105.             
  106.             self.cigarettelit = 0
  107.             self.nextsmoketime = level.time + ((randomint 150)/10) + 15
  108.             
  109.             //println "Done throwing away cigarette"
  110.         }
  111.     }
  112.         
  113. end
  114.  
  115. //===================================================================================
  116. //This should be called before changing states (idle,stand,attack,aim,shoot..etc etc)
  117. //SmokeThrowCigarette:
  118. //    if (self.cigarettelit > 0)
  119. //    {
  120. //        self.blendtime = 0.5
  121. //        self setupperanim (smoking05)
  122. //        self waittill upperanimdone
  123. //        self.cigarettelit = 0
  124. //    }
  125. //end
  126.  
  127.  
  128. //===================================================================================
  129. //This is basically called by the pain script to remove cigarettes
  130. SmokeRemoveCigarette:
  131.     //if (self.smokinginitialized == "yes")
  132.     //{
  133.         if (self.cigarettelit == 1)
  134.         {
  135.             self removeattachedmodel "Bip01 L Finger11"
  136.             self.cigarettelit = 0
  137.         }
  138.     //}
  139. end
  140.  
  141.